#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    connect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleclick1);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handleclick1()
{
    this->setWindowTitle("世界很美好");
    qDebug() << "handleclick1";
}

void Widget::handleclick2()
{
    this->setWindowTitle("我一定会成功");
    qDebug() << "handleclick2";
}


void Widget::on_pushButton_2_clicked()
{
    // 取消按钮1原本的信号与槽的连接
    disconnect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleclick1);
    // 重新建立连接
    connect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleclick2);
}

